import request from '@/utils/request'

/**
 * 获取组织架构
 * @returns promise
 */
export function getDepartments() {
  return request({
    url: '/company/department',
    method: 'GET'
  })
}

/**
 * 根据部门id删除部门
 * @param {*} id 部门id
 * @returns promise
 */
export function delDeptById(id) {
  return request({
    url: '/company/department/' + id,
    method: 'DELETE'
  })
}

/**
 * 新增部门
 * @param {*} data {code:部门编码,introduce:介绍,manager:负责人名称,name:部门名称}
 * @returns promise
 */
export function addDepartments(data) {
  return request({
    url: '/company/department',
    method: 'POST',
    data
  })
}

/**
 * 根据id修改部门详情
 * @param {*} data {code,id,introduce,manager,name}
 * @returns promise
 */
export function updateDepartments(data) {
  return request({
    url: '/company/department/' + data.id,
    method: 'PUT',
    data
  })
}
